Skip to content

RUN-4466: Block cross-origin HTTP redirects to prevent credential exfiltration - #609

Merged
ronaveva merged 2 commits into
mainfrom
enh/RUN-4466-block-cross-origin-redirects
May 22, 2026
Merged

RUN-4466: Block cross-origin HTTP redirects to prevent credential exfiltration#609
ronaveva merged 2 commits into
mainfrom
enh/RUN-4466-block-cross-origin-redirects

Conversation

@ronaveva

@ronaveva ronaveva commented May 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes a credential exfiltration vulnerability (HackerOne #3655293) where rd-cli-tool would forward authentication credentials to redirect targets without checking if they were on a different origin.

  • Adds CrossOriginRedirectInterceptor as a network interceptor that aborts 3xx redirects to a different scheme/host/port
  • Default behavior: block with a clear IOException naming the blocked URL
  • Opt-in to original behavior: RD_ALLOW_CROSS_ORIGIN_REDIRECT=true or --allow-cross-origin-redirect CLI flag (prints a security warning)

Affected authentication modes

  • Token-based: X-Rundeck-Auth-Token header no longer leaked on cross-origin redirect
  • Password-based: j_username/j_password form body no longer leaked via 307 redirect

Changes

  • CrossOriginRedirectInterceptor.java — new network interceptor (blocks/allows based on config)
  • RundeckClient.java — registers the interceptor; adds RD_ALLOW_CROSS_ORIGIN_REDIRECT env var constant and builder method
  • Main.java — adds --allow-cross-origin-redirect CLI flag; shows security warning when opt-in is active
  • CrossOriginRedirectInterceptorSpec.groovy — 11 Spock unit tests covering all acceptance criteria

Test plan

  • All existing tests pass (./gradlew test)
  • CrossOriginRedirectInterceptorSpec: 302/307 to different host/scheme/port blocked by default
  • Same-origin redirects pass through unchanged
  • Opt-in via env var and CLI flag allows original behavior
  • Error message includes blocked URL and hints at opt-in flag
  • Manual verification with PoC from HackerOne #3655293 (see ticket RUN-4466)

References

🤖 Generated with Claude Code

ronaveva and others added 2 commits May 19, 2026 15:53
…iltration

Add CrossOriginRedirectInterceptor as a network interceptor that aborts any
3xx redirect whose Location resolves to a different scheme, host, or port than
the original request URL. This prevents authentication credentials
(X-Rundeck-Auth-Token header, j_username/j_password form body) from being
leaked to attacker-controlled hosts via malicious redirects.

Default behavior: cross-origin redirects throw IOException with a clear
message including the blocked URL.

Opt-in to original behavior via:
- RD_ALLOW_CROSS_ORIGIN_REDIRECT=true environment variable
- --allow-cross-origin-redirect CLI flag

A warning is printed to stderr when the opt-in is active.

Fixes HackerOne report #3655293.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Declare the flag as a @option on Main so picocli accepts it during
argument parsing. Without this, picocli threw 'Unknown option' even
though the pre-processing logic in main() already handled it.

Add MainSpec covering flag recognition, default-false behaviour, and
the system property pre-processing logic.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@Jesus-Osuna-M Jesus-Osuna-M left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and verified the fix manually against a live staging RBA instance (v5.21). The CrossOriginRedirectInterceptor correctly blocks cross-origin redirects by default — confirmed the token leak on main (no fix) and the block on this branch. Opt-in via RD_ALLOW_CROSS_ORIGIN_REDIRECT=true and --allow-cross-origin-redirect both work correctly with a visible warning. No regressions found in normal same-origin CLI operations. LGTM ✅

@ronaveva
ronaveva merged commit efd0228 into main May 22, 2026
10 checks passed
@ronaveva
ronaveva deleted the enh/RUN-4466-block-cross-origin-redirects branch May 22, 2026 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants